<template>
  <div class="my-app" :class="classes">
    <slot v-if="isMicroApp"></slot>
    <template v-else>
      <keep-alive>
        <router-view v-if="$route.meta.keepAlive"></router-view>
      </keep-alive>
      <router-view v-if="!$route.meta.keepAlive"></router-view>
    </template>
  </div>
</template>

<script>
  import Scale from '$ui/utils/scale'

  export default {
    name: 'MyApp',
    mixins: [Scale],
    props: {

      // 适应父容器
      fit: Boolean,

      // 应用列表
      apps: {
        type: Array,
        default() {
          return []
        }
      }
    },
    computed: {
      classes() {
        return {
          'is-fit': this.fit
        }
      },
      isMicroApp() {
        const path = this.$route.path
        return this.apps.some(app => {
          const name = typeof app === 'object' ? app.name : app
          return path.startsWith(`/${name}`)
        })
      }
    }
  }
</script>



